/**
 * 学习课程 列表页 JS 脚本
 * @author 金杰 , maillank@qq.com
 * @since 2024-09-18 16:56:41
 */


function ListPage() {

	var settings, admin, form, table, layer, util, fox;


	const moduleURL = "/service-hr/hr-learn";

	/**
	 * 入口函数，初始化
	 */
	this.init = function (layui) {
		admin = layui.admin, settings = layui.settings, form = layui.form,   laydate = layui.laydate;
		table = layui.table, layer = layui.layer, util = layui.util, fox = layui.foxnic, dropdown = layui.dropdown;


		$("#finishFile").click(function () {
			if (role == "review") {
				layer.msg("当前预览模式,按钮无效");
			} else {
				finish(taskData.id, "finishVideo");
			}
		})
		$("#finishVideo").click(function () {
			if (role == "review") {
				layer.msg("当前预览模式,按钮无效");
			} else {
				finish(taskData.id, "finishVideo");
			}
		})

		function finish(taskId, btn) {
			top.layer.confirm(fox.translate('是否完成本次学习？'), function (i) {
				top.layer.close(i);
					admin.post(moduleURL + "/finish", {taskId: taskId}, function (data) {
						if (data.success) {
							fox.showMessage(data);
							admin.finishPopupCenterById('hr-learn-task-data-win');
						} else {
							fox.showMessage(data);
						}
					}, {delayLoading: 200, elms: [$("#" + btn)]});
			});
		}

	}
}
layui.use(['form', 'table', 'util', 'settings', 'admin','foxnic','laydate','dropdown'],function() {
	var task=setInterval(function (){
		if(!window["pageExt"]) return;
		clearInterval(task);
		(new ListPage()).init(layui);
	},1);
});
